#include <unittest/unittest.h>

#include <cusp/array2d.h>
#include <cusp/coo_matrix.h>
#include <cusp/csr_matrix.h>
#include <cusp/dia_matrix.h>
#include <cusp/ell_matrix.h>
#include <cusp/hyb_matrix.h>

#include <cusp/gallery/eye.h>

template <class Matrix>
void TestEyeMatrix(void)
{
	typedef typename Matrix::value_type ValueType;

	Matrix A;
	cusp::gallery::eye(A, 4, 5);

	ASSERT_EQUAL(A.num_rows, 4);
	ASSERT_EQUAL(A.num_cols, 5);

	cusp::array2d<ValueType, cusp::host_memory, cusp::row_major> B = A;
	ASSERT_EQUAL(B.num_rows, 4);
	ASSERT_EQUAL(B.num_cols, 5);
	for (size_t i = 0; i < B.num_rows; ++i)
		for (size_t j = 0; j < B.num_cols; ++j)
		{
			if (i == j)
				ASSERT_EQUAL(B(i,j), ValueType(1.0));
			else
				ASSERT_EQUAL(B(i,j), ValueType(0.0));
		}
}
DECLARE_MATRIX_UNITTEST(TestEyeMatrix)

